local skel = fk.CreateSkill {
  name = "emo__chenglu",
}

Fk:loadTranslationTable{
  ["emo__chenglu"] = "承露",
  [":emo__chenglu"] = "每当手牌数最小的角色于回合外成为牌的目标后，你可以令其摸一张牌，当其手牌数为最大时，其不能使用以此法摸的牌。",

  ["#emo__chenglu-ask"] = "承露:你可以令 %src 摸一张牌",
  ["@@emo__chenglu-inhand"] = "承露",
}

skel:addEffect(fk.TargetConfirmed, {
  anim_type = "support",
  can_trigger = function (self, event, target, player, data)
    if player:hasSkill(skel.name) and data.to and not data.to.dead and data.to.phase == Player.NotActive then
      return table.every(player.room.alive_players, function (p)
        return p:getHandcardNum() >= data.to:getHandcardNum()
      end)
    end
  end,
  on_cost = function (self, event, target, player, data)
    if player.room:askToSkillInvoke(player, {skill_name = skel.name, prompt = "#emo__chenglu-ask:"..data.to.id }) then
      event:setCostData(self, {tos = { data.to } })
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    data.to:drawCards(1, skel.name, nil, "@@emo__chenglu-inhand")
  end,
})

skel:addEffect("prohibit", {
  prohibit_use = function (self, player, card)
    if table.every(Fk:currentRoom().alive_players, function (p)
      return p:getHandcardNum() <= player:getHandcardNum()
    end) then
      return table.find(Card:getIdList(card), function (id)
        return Fk:getCardById(id):getMark("@@emo__chenglu-inhand") ~= 0
      end) ~= nil
    end
  end,
})

return skel
